package dart

class AttemptTests extends DartTestCase {
	Classification class2 = new Classification(scoreMultiplier:2, penaltyMultiplier:2)
	
	void testGetPenaltyScoreWithoutMainPenalty() {
		Game game = new Game(harshAndMainPenalties: false)
		PlayerGame playerGame = addPlayerGame(game)
		Round round = addRound(playerGame)
		Attempt attempt = addPenalty(round, 20, 100)
		
		assertEquals(-100, attempt.score);

		attempt.harshPenalty = 0
		assertEquals(0, attempt.score);

		attempt.harshPenalty = 25
		assertEquals(-25, attempt.score);
	}

	void testGetPenaltyScoreWithMainPenaltyGreater() {
		Game game = new Game(harshAndMainPenalties: true)
		PlayerGame playerGame = addPlayerGame(game)
		Round round = addRound(playerGame)
		Attempt attempt = addPenalty(round, 20, 30)
		attempt.classification = class2;

		assertEquals(-40, attempt.score);
	}

	void testGetPenaltyScoreWithMainPenaltyLesser() {
		Game game = new Game(harshAndMainPenalties: true)
		PlayerGame playerGame = addPlayerGame(game)
		Round round = addRound(playerGame)
		Attempt attempt = addPenalty(round, 10, 30)
		attempt.classification = class2;

		assertEquals(-30, attempt.score);
	}

	void testGetMissScore() {
		Game game = new Game(harshAndMainPenalties: true)
		PlayerGame playerGame = addPlayerGame(game)
		Round round = addRound(playerGame)
		Attempt attempt = addMiss(round)

		assertEquals(0, attempt.score);

		attempt.value = 100;
		assertEquals(0, attempt.score);
	}

	void testGetSuccessScore() {
		Game game = new Game(harshAndMainPenalties: true)
		PlayerGame playerGame = addPlayerGame(game)
		Round round = addRound(playerGame)
		Attempt attempt = addSuccess(round, 10, 10)
		attempt.classification = class2;

		assertEquals(200, attempt.score);

		attempt.value = 20;
		attempt.multiplier = 1;
		assertEquals(40, attempt.score);
	}

}